

"""
15
5
1 1
2 2
3 3
2 1
2 3
"""


def main():
    r = int(input())
    n = int(input())
    rsq = r * r
    vm = [[int(x) for x in input().split()] for _ in range(n)]
    mc = {}
    for m in vm:
        cx, cy = m
        for y in range(cy - r, cy + r + 1):
            if y not in mc:
                mc[y] = {}
            rm = mc[y]
            for x in range(cx - r, cx + r + 1):
                if sq(y - cy) + sq(x - cx) > rsq:
                    continue
                if x not in rm:
                    rm[x] = 0
                rm[x] += 1
    mh, sx, sy = -1, -1, -1
    for ky in mc:
        rm = mc[ky]
        for kx in rm:
            if (mh < rm[kx]) or (mh == rm[kx] and (sx < kx or (sx == kx and sy < ky))):
                mh = rm[kx]
                sx = kx
                sy = ky
    print(sx, sy)


def sq(x):
    return x * x

if __name__ == "__main__":
    main()
